package org.takeback.chat.utils;

import java.util.Calendar;

public class PriceMapperUtil {
	private static volatile int random = 0;
	
	private static String timespace = DateUtil.toShortTime(Calendar.getInstance().getTime(), "yyyMMdd");
	
	public static double getPiancha(double price) {
		double piancha;
		if(DateUtil.toShortTime(Calendar.getInstance().getTime(), "yyyMMdd").equals(timespace)
				&& random < 100) {
			piancha = random++;
		}else {
			random = 0;
			piancha = random++;
			timespace = DateUtil.toShortTime(Calendar.getInstance().getTime(), "yyyMMdd");
		}
		return (double) Math.round((price*100 - piancha))/100.0;
	}
}
